home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 6 / QRZ Ham Radio Callsign Database - Volume 6.iso / pc / files / dsp / dspkgctr.z / dspkgctr / gcc / toplev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-08  |  63.8 KB  |  2,644 lines

  1. /* Top level of GNU C compiler
  2.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  3.  
  4.     $Id: toplev.c,v 1.37 91/10/31 17:04:25 pete Exp $
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 1, or (at your option)
  11. any later version.
  12.  
  13. GNU CC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with GNU CC; see the file COPYING.  If not, write to
  20. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22.  
  23. /* This is the top level of cc1.
  24.    It parses command args, opens files, invokes the various passes
  25.    in the proper order, and counts the time used by each.
  26.    Error messages and low-level interface to malloc also handled here.  */
  27.  
  28. #include "config.h"
  29. #include <stdio.h>
  30. #include <signal.h>
  31. #include <setjmp.h>
  32.  
  33. #include <sys/types.h>
  34. #include <sys/stat.h>
  35.  
  36. #if defined( _MSDOS )
  37. #include <time.h>
  38. #include <stdlib.h>
  39. #include <stdarg.h>
  40. #else
  41. #ifdef USG
  42. #undef FLOAT
  43. #include <sys/param.h>
  44. /* This is for hpux.  It is a real screw.  They should change hpux.  */
  45. #undef FLOAT
  46. #include <sys/times.h>
  47. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  48. #undef FFS  /* Some systems define this in param.h.  */
  49. #else
  50. #ifndef VMS
  51. #include <sys/time.h>
  52. #include <sys/resource.h>
  53. #endif
  54. #endif
  55. #endif
  56.  
  57. #include "input.h"
  58. #include "tree.h"
  59. #include "c-tree.h"
  60. #include "rtl.h"
  61. #include "flags.h"
  62.  
  63. extern int yydebug;
  64.  
  65. extern FILE *finput;
  66.  
  67. extern int reload_completed;
  68. extern int rtx_equal_function_value_matters;
  69.  
  70. extern void init_lex ();
  71. extern void init_decl_processing ();
  72. extern void init_tree ();
  73. extern void init_rtl ();
  74. extern void init_optabs ();
  75. extern void init_reg_sets ();
  76. extern void dump_flow_info ();
  77. extern void dump_local_alloc ();
  78.  
  79. void rest_of_decl_compilation ();
  80. #if defined ( _MSDOS )
  81. void fatal( char * s, ... );
  82. void error ( char *, ... );
  83. void error_with_file_and_line ( char * file, ... );
  84. void error_with_decl ( tree decl, ... );
  85. void error_for_asm ( rtx insn, ... );
  86. void warning_with_file_and_line ( char * file, ... );
  87. void warning ( char * s, ... );
  88. void warning_with_decl ( tree decl,  ... );
  89. void sorry ( char * s, ... );
  90. void really_sorry ( char * s, ... );
  91. #else
  92. void error ();
  93. #endif
  94. #if ! defined( _MSDOS )
  95. void error_with_file_and_line ();
  96. #endif
  97. void fancy_abort ();
  98. void set_target_switch ();
  99. void print_target_switch_defaults ();
  100.  
  101. /* Bit flags that specify the machine subtype we are compiling for.
  102.    Bits are tested using macros TARGET_... defined in the tm-...h file
  103.    and set by `-m...' switches.  */
  104.  
  105. int target_flags;
  106.  
  107. /* Name of current original source file (what was input to cpp).
  108.    This comes from each #-command in the actual input.  */
  109.  
  110. char *input_filename;
  111.  
  112. /* Name of top-level original source file (what was input to cpp).
  113.    This comes from the #-command at the beginning of the actual input.
  114.    If there isn't any there, then this is the cc1 input file name.  */
  115.  
  116. char *main_input_filename;
  117.  
  118. /* Current line number in real source file.  */
  119.  
  120. #if defined( _MSDOS )
  121. /* there really is a duplicate definition in c-parse.y */
  122. extern int lineno;
  123. #else
  124. int lineno;
  125. #endif
  126.  
  127. #if defined( DSP56000 ) || defined( DSP96000 )
  128. /* version string for internal tracking of released versions */
  129. extern char* motorola_version_string;
  130. extern char* version_string;
  131. #endif
  132.  
  133. /* Stack of currently pending input files.  */
  134.  
  135. struct file_stack *input_file_stack;
  136.  
  137. /* Incremented on each change to input_file_stack.  */
  138. int input_file_stack_tick;
  139.  
  140. /* FUNCTION_DECL for function now being parsed or compiled.  */
  141.  
  142. extern tree current_function_decl;
  143.  
  144. /* Name to use as base of names for dump output files.  */
  145.  
  146. char *dump_base_name;
  147.  
  148. /* Flags saying which kinds of debugging dump have been requested.  */
  149.  
  150. int rtl_dump = 0;
  151. int rtl_dump_and_exit = 0;
  152. int jump_opt_dump = 0;
  153. int cse_dump = 0;
  154. int loop_dump = 0;
  155. int flow_dump = 0;
  156. int combine_dump = 0;
  157. int local_reg_dump = 0;
  158. int global_reg_dump = 0;
  159. int jump2_opt_dump = 0;
  160. int dbr_sched_dump = 0;
  161.  
  162. /* 1 => write gdb debugging output (using symout.c).  -g
  163.    2 => write dbx debugging output (using dbxout.c).  -G
  164.    3 => write sdb debugging output (using sdbout.c).  -g.  */
  165.  
  166. enum debugger write_symbols = NO_DEBUG;
  167.  
  168. /* Nonzero means can use our own extensions to DBX format.
  169.    Relevant only with write_symbols == DBX_DEBUG.  */
  170.  
  171. int use_gdb_dbx_extensions;
  172.  
  173. /* Nonzero means do optimizations.  -opt.  */
  174.  
  175. int optimize = 0;
  176.  
  177. #if defined( DSP56000 ) || defined( DSP96000 )
  178. /* no effect dummy flag */
  179.  
  180. int flag_no_effect = 0;
  181. #endif
  182.  
  183. /* Nonzero means `char' should be signed.  */
  184.  
  185. int flag_signed_char;
  186.  
  187. /* Nonzero means give an enum type only as many bytes as it needs.  */
  188.  
  189. int flag_short_enums;
  190.  
  191. /* Nonzero for -fcaller-saves: allocate values in regs that need to
  192.    be saved across function calls, if that produces overall better code.
  193.    Optional now, so people can test it.  */
  194.  
  195. #ifdef DEFAULT_CALLER_SAVES
  196. int flag_caller_saves = 1;
  197. #else
  198. int flag_caller_saves = 0;
  199. #endif
  200.  
  201. /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
  202.  
  203. int flag_pcc_struct_return = 0;
  204.  
  205. /* Nonzero for -fforce-mem: load memory value into a register
  206.    before arithmetic on it.  This makes better cse but slower compilation.  */
  207.  
  208. int flag_force_mem = 0;
  209.  
  210. /* Nonzero for -fforce-addr: load memory address into a register before
  211.    reference to memory.  This makes better cse but slower compilation.  */
  212.  
  213. int flag_force_addr = 0;
  214.  
  215. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  216.    instead save them up to pop many calls' args with one insns.  */
  217.  
  218. int flag_defer_pop = 1;
  219.  
  220. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  221.    in extended-precision registers.  */
  222.  
  223. int flag_float_store = 0;
  224.  
  225. /* Nonzero for -fcombine-regs:
  226.    allow instruction combiner to combine an insn
  227.    that just copies one reg to another.  */
  228.  
  229. int flag_combine_regs = 0;
  230.  
  231. /* Nonzero enables strength-reduction in loop.c.  */
  232.  
  233. #if defined( DSP56000 ) || defined( DSP96000 )
  234. /* strength-reduce and dsp loop opto on! */
  235. int flag_strength_reduce = 1;
  236. #else
  237. int flag_strength_reduce = 0;
  238. #endif
  239.  
  240. /* Nonzero for -fwritable-strings:
  241.    store string constants in data segment and don't uniquize them.  */
  242.  
  243. int flag_writable_strings = 0;
  244.  
  245. /* Nonzero means don't put addresses of constant functions in registers.
  246.    Used for compiling the Unix kernel, where strange substitutions are
  247.    done on the assembly output.  */
  248.  
  249. int flag_no_function_cse = 0;
  250.  
  251. /* Nonzero for -fomit-frame-pointer:
  252.    don't make a frame pointer in simple functions that don't require one.  */
  253.  
  254. int flag_omit_frame_pointer = 0;
  255.  
  256. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  257.  
  258. int flag_no_peephole = 0;
  259.  
  260. /* Nonzero means all references through pointers are volatile.  */
  261.  
  262. int flag_volatile;
  263.  
  264. /* Nonzero means just do syntax checking; don't output anything.  */
  265.  
  266. int flag_syntax_only = 0;
  267.  
  268. /* Nonzero means do stupid register allocation.  -noreg.
  269.    This and `optimize' are controlled by different switches in cc1,
  270.    but normally cc controls them both with the -O switch.  */
  271.  
  272. int obey_regdecls = 0;
  273.  
  274. /* Don't print functions as they are compiled and don't print
  275.    times taken by the various passes.  -quiet.  */
  276.  
  277. int quiet_flag = 0;
  278.  
  279. /* Don't print warning messages.  -w.  */
  280.  
  281. int inhibit_warnings = 0;
  282.  
  283. /* Do print extra warnings (such as for uninitialized variables).  -W.  */
  284.  
  285. int extra_warnings = 0;
  286.  
  287. /* Nonzero to warn about unused local variables.  */
  288.  
  289. int warn_unused;
  290.  
  291. /* Nonzero means warn about all declarations which shadow others.   */
  292.  
  293. int warn_shadow;
  294.  
  295. /* Warn if a switch on an enum fails to have a case for every enum value.  */
  296.  
  297. int warn_switch;
  298.  
  299. /* Nonzero means warn about any identifiers that match in the first N
  300.    characters.  The value N is in `id_clash_len'.  */
  301.  
  302. int warn_id_clash;
  303. int id_clash_len;
  304.  
  305. /* Number of error messages and warning messages so far.  */
  306.  
  307. int errorcount = 0;
  308. int warningcount = 0;
  309. int sorrycount = 0;
  310.  
  311. /* Name of program invoked, sans directories.  */
  312.  
  313. char *progname;
  314.  
  315. /* Nonzero if generating code to do profiling.  */
  316.  
  317. int profile_flag = 0;
  318.  
  319. /* Nonzero if generating code to do profiling on a line-by-line basis.  */
  320.  
  321. int profile_block_flag;
  322.  
  323. /* Nonzero for -pedantic switch: warn about anything
  324.    that standard spec forbids.  */
  325.  
  326. int pedantic = 0;
  327.  
  328. /* Nonzero for -finline-functions: ok to inline functions that look like
  329.    good inline candidates.  */
  330.  
  331. int flag_inline_functions;
  332.  
  333. /* Nonzero for -fkeep-inline-functions: even if we make a function
  334.    go inline everywhere, keep its defintion around for debugging
  335.    purposes.  */
  336.  
  337. int flag_keep_inline_functions;
  338.  
  339. # if ! defined( DSP96000 ) && ! defined( DSP56000 )
  340. /* Nonzero means make the text shared if supported.  */
  341.  
  342. int flag_shared_data;
  343.  
  344. # else
  345. /* zero means make the text shared if supported.  */
  346.  
  347. int flag_shared_data = 1;
  348.  
  349. # endif
  350.  
  351. /* Nonzero means schedule into delayed branch slots if supported.  */
  352.  
  353. int flag_delayed_branch;
  354.  
  355. /* Copy of arguments to main.  */
  356. int save_argc;
  357. char **save_argv;
  358.  
  359. /* Name for output file of assembly code, specified with -o.  */
  360.  
  361. char *asm_file_name;
  362.  
  363. /* Name for output file of GDB symbol segment, specified with -symout.  */
  364.  
  365. char *sym_file_name;
  366.  
  367. /* Table of language-independent -f options.
  368.    STRING is the option name.  VARIABLE is the address of the variable.
  369.    ON_VALUE is the value to store in VARIABLE
  370.     if `-fSTRING' is seen as an option.
  371.    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
  372.  
  373. struct { char *string; int *variable; int on_value;} f_options[] =
  374. {
  375.   {"float-store", &flag_float_store, 1},
  376.   {"volatile", &flag_volatile, 1},
  377.   {"defer-pop", &flag_defer_pop, 1},
  378.   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
  379.   {"strength-reduce", &flag_strength_reduce, 1},
  380.   {"writable-strings", &flag_writable_strings, 1},
  381.   {"peephole", &flag_no_peephole, 0},
  382.   {"force-mem", &flag_force_mem, 1},
  383.   {"force-addr", &flag_force_addr, 1},
  384.   {"combine-regs", &flag_combine_regs, 1},
  385.   {"function-cse", &flag_no_function_cse, 0},
  386.   {"inline-functions", &flag_inline_functions, 1},
  387.   {"keep-inline-functions", &flag_keep_inline_functions, 1},
  388.   {"syntax-only", &flag_syntax_only, 1},
  389.   {"shared-data", &flag_shared_data, 1},
  390.   {"caller-saves", &flag_caller_saves, 1},
  391.   {"pcc-struct-return", &flag_pcc_struct_return, 1},
  392. #if defined( DSP56000 ) || defined( DSP96000 )
  393.   {"delayed-branch", &flag_delayed_branch, 1},
  394.   {"opt", &flag_no_effect, 0},
  395.   {"coalescer", &flag_no_effect, 0}
  396. #else
  397.   {"delayed-branch", &flag_delayed_branch, 1}
  398. #endif
  399. };
  400.  
  401. /* Output files for assembler code (real compiler output)
  402.    and debugging dumps.  */
  403.  
  404. FILE *asm_out_file;
  405. FILE *rtl_dump_file;
  406. FILE *jump_opt_dump_file;
  407. FILE *cse_dump_file;
  408. FILE *loop_dump_file;
  409. FILE *flow_dump_file;
  410. FILE *combine_dump_file;
  411. FILE *local_reg_dump_file;
  412. FILE *global_reg_dump_file;
  413. FILE *jump2_opt_dump_file;
  414. FILE *dbr_sched_dump_file;
  415.  
  416. /* Time accumulators, to count the total time spent in various passes.  */
  417.  
  418. int parse_time;
  419. int varconst_time;
  420. int integration_time;
  421. int jump_time;
  422. int cse_time;
  423. int loop_time;
  424. int flow_time;
  425. int combine_time;
  426. int local_alloc_time;
  427. int global_alloc_time;
  428. int dbr_sched_time;
  429. int final_time;
  430. int symout_time;
  431. int dump_time;
  432.  
  433. /* Return time used so far, in microseconds.  */
  434.  
  435. int
  436. gettime ()
  437. {
  438. #if defined( _MSDOS )
  439.   time_t tms;
  440. #else
  441. #ifdef USG
  442.   struct tms tms;
  443. #else
  444. #ifndef VMS
  445.   struct rusage rusage;
  446. #else /* VMS */
  447.   struct
  448.     {
  449.       int proc_user_time;
  450.       int proc_system_time;
  451.       int child_user_time;
  452.       int child_system_time;
  453.     } vms_times;
  454. #endif
  455. #endif
  456. #endif
  457.  
  458.   if (quiet_flag)
  459.     return 0;
  460.  
  461. #if defined( _MSDOS )
  462.   time (&tms);
  463.   return tms;
  464. #else
  465. #ifdef USG
  466.   times (&tms);
  467.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  468. #else
  469. #ifndef VMS
  470.   getrusage (0, &rusage);
  471.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  472.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  473. #else /* VMS */
  474.   times (&vms_times);
  475.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  476. #endif
  477. #endif
  478. #endif
  479. }
  480.  
  481. #define TIMEVAR(VAR, BODY)    \
  482. do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
  483.  
  484. void
  485. print_time (str, total)
  486.      char *str;
  487.      int total;
  488. {
  489.   fprintf (stderr,
  490.        "time in %s: %d.%06d\n",
  491.        str, total / 1000000, total % 1000000);
  492. }
  493.  
  494. /* Count an error or warning.  Return 1 if the message should be printed.  */
  495.  
  496. int
  497. count_error (warningp)
  498.      int warningp;
  499. {
  500.   if (warningp && inhibit_warnings)
  501.     return 0;
  502.  
  503.   if (warningp)
  504.     warningcount++;
  505.   else
  506.     errorcount++;
  507.  
  508.   return 1;
  509. }
  510.  
  511. /* Print a fatal error message.  NAME is the text.
  512.    Also include a system error message based on `errno'.  */
  513.  
  514. void
  515. pfatal_with_name (name)
  516.      char *name;
  517. {
  518.   fprintf (stderr, "%s: ", progname);
  519.   perror (name);
  520.   exit (35);
  521. }
  522.  
  523. void
  524. fatal_io_error (name)
  525.      char *name;
  526. {
  527.   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
  528.   exit (35);
  529. }
  530.  
  531. #if ! defined ( _MSDOS )
  532. void
  533. fatal (s, v)
  534.      char *s;
  535.      int v;
  536. #else
  537. void fatal( char * s, ... )
  538. #endif
  539. {
  540. #if defined (_MSDOS )
  541.     int v;
  542.     va_list ap;
  543.  
  544.     va_start( ap, s );
  545.  
  546.     /* make the faulty assumption that v and v2 exist */
  547.     v = va_arg( ap, int );
  548. #endif
  549.   error (s, v);
  550. #if defined (_MSDOS )
  551.     va_end( ap );
  552. #endif
  553.   exit (34);
  554. }
  555.  
  556. /* Called from insn-extract to give a better error message when we
  557.    don't have an insn to match what we are looking for, rather
  558.    than just calling abort().  */
  559.  
  560. void
  561. fatal_insn_not_found (insn)
  562.      rtx insn;
  563. {
  564.   error ("The following insn was not recognizable:", 0);
  565.   debug_rtx (insn);
  566.   abort ();
  567. }
  568.  
  569. static int need_error_newline;
  570.  
  571. /* Function of last error message;
  572.    more generally, function such that if next error message is in it
  573.    then we don't have to mention the function name.  */
  574. static tree last_error_function = NULL;
  575.  
  576. /* Used to detect when input_file_stack has changed since last described.  */
  577. static int last_error_tick;
  578.  
  579. /* Called when the start of a function definition is parsed,
  580.    this function prints on stderr the name of the function.  */
  581.  
  582. void
  583. announce_function (decl)
  584.      tree decl;
  585. {
  586.   if (! quiet_flag)
  587.     {
  588.       fprintf (stderr, " %s", DECL_PRINT_NAME (decl));
  589.       fflush (stderr);
  590.       need_error_newline = 1;
  591.       last_error_function = current_function_decl;
  592.     }
  593. }
  594.  
  595. /* Prints out, if necessary, the name of the current function
  596.    which caused an error.  Called from all error and warning functions.  */
  597.  
  598. void
  599. report_error_function (file)
  600.      char *file;
  601. {
  602.   struct file_stack *p;
  603.  
  604.   if (need_error_newline)
  605.     {
  606.       fprintf (stderr, "\n");
  607.       need_error_newline = 0;
  608.     }
  609.  
  610.   if (last_error_function != current_function_decl)
  611.     {
  612.       if (file)
  613.     fprintf (stderr, "%s: ", file);
  614.  
  615.       if (current_function_decl == NULL)
  616.     fprintf (stderr, "At top level:\n");
  617.       else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
  618.     fprintf (stderr, "In method %s:\n",
  619.          DECL_PRINT_NAME (current_function_decl));
  620.       else
  621.     fprintf (stderr, "In function %s:\n",
  622.          DECL_PRINT_NAME (current_function_decl));
  623.  
  624.       last_error_function = current_function_decl;
  625.     }
  626.   if (input_file_stack && input_file_stack->next != 0
  627.       && input_file_stack_tick != last_error_tick)
  628.     {
  629.       fprintf (stderr, "In file included");
  630.       for (p = input_file_stack->next; p; p = p->next)
  631.     {
  632.       fprintf (stderr, " from %s:%d", p->name, p->line);
  633.       if (p->next)
  634.         fprintf (stderr, ",");
  635.     }
  636.       fprintf (stderr, ":\n");
  637.       last_error_tick = input_file_stack_tick;
  638.     }
  639. }
  640.  
  641. /* Report an error at the current line number.
  642.    S and V are a string and an arg for `printf'.  */
  643.  
  644. #if ! defined( _MSDOS )
  645. void
  646. error (s, v, v2)
  647.      char *s;
  648.      int v;            /* @@also used as pointer */
  649.      int v2;            /* @@also used as pointer */
  650. #else
  651. void error ( char *s, ... )
  652. #endif
  653. {
  654. #if defined (_MSDOS )
  655.     int v, v2;
  656.     va_list ap;
  657.  
  658.     va_start( ap, s );
  659.  
  660.     /* make the faulty assumption that v and v2 exist */
  661.     v = va_arg( ap, int );
  662.     v2 = va_arg( ap, int );
  663. #endif
  664.     error_with_file_and_line (input_filename, lineno, s, v, v2);
  665. #if defined (_MSDOS )
  666.     va_end( ap );
  667. #endif
  668. }
  669.  
  670. /* Report an error at line LINE of file FILE.
  671.    S and V are a string and an arg for `printf'.  */
  672.  
  673. #if ! defined( _MSDOS )
  674. void
  675. error_with_file_and_line (file, line, s, v, v2)
  676.      char *file;
  677.      int line;
  678.      char *s;
  679.      int v;
  680.      int v2;
  681. #else
  682. void  error_with_file_and_line ( char * file, ... )
  683. #endif
  684. {
  685. #if defined (_MSDOS )
  686.     char *s;
  687.     int line, v, v2;
  688.     va_list ap;
  689.  
  690.     va_start( ap, file );
  691.  
  692.     /* make the faulty assumption that v and v2 exist */
  693.     line = va_arg( ap, int );
  694.     s = va_arg( ap, char * );
  695.     v = va_arg( ap, int );
  696.     v2 = va_arg( ap, int );
  697. #endif
  698.   count_error (0);
  699.  
  700.   report_error_function (file);
  701.  
  702.   if (file)
  703.     fprintf (stderr, "%s:%d: ", file, line);
  704.   else
  705.     fprintf (stderr, "%s: ", progname);
  706.   fprintf (stderr, s, v, v2);
  707.   fprintf (stderr, "\n");
  708. #if defined (_MSDOS )
  709.     va_end( ap );
  710. #endif
  711. }
  712.  
  713. /* Report an error at the declaration DECL.
  714.    S and V are a string and an arg which uses %s to substitute the declaration name.  */
  715.  
  716. #if ! defined( _MSDOS )
  717. void
  718. error_with_decl (decl, s, v)
  719.      tree decl;
  720.      char *s;
  721.      int v;
  722. #else
  723. void error_with_decl ( tree decl, ... )
  724. #endif
  725. {
  726. #if defined (_MSDOS )
  727.     char *s;
  728.     int v;
  729.     va_list ap;
  730.  
  731.     va_start( ap, decl );
  732.     s = va_arg( ap, char * );
  733.     v = va_arg( ap, int );
  734. #endif
  735.   count_error (0);
  736.  
  737.   report_error_function (DECL_SOURCE_FILE (decl));
  738.  
  739.   fprintf (stderr, "%s:%d: ",
  740.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  741.  
  742.   if (DECL_PRINT_NAME (decl))
  743.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  744.   else if (DECL_NAME (decl))
  745.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  746.   else
  747.     fprintf (stderr, s, "((anonymous))", v);
  748.   fprintf (stderr, "\n");
  749. #if defined (_MSDOS )
  750.     va_end( ap );
  751. #endif
  752. }
  753.  
  754. /* Report an error at the line number of the insn INSN.
  755.    S and V are a string and an arg for `printf'.
  756.    This is used only when INSN is an `asm' with operands,
  757.    and each ASM_OPERANDS records its own source file and line.  */
  758.  
  759. #if ! defined( _MSDOS )
  760. void
  761. error_for_asm (insn, s, v, v2)
  762.      rtx insn;
  763.      char *s;
  764.      int v;            /* @@also used as pointer */
  765.      int v2;            /* @@also used as pointer */
  766. #else
  767. void error_for_asm ( rtx insn, ... )
  768. #endif
  769. {
  770.   rtx temp;
  771.   char *filename;
  772.   int line;
  773.   rtx body = PATTERN (insn);
  774.   rtx asmop;
  775.  
  776. #if defined (_MSDOS )
  777.     char *s;
  778.     int v, v2;
  779.     va_list ap;
  780.  
  781.     va_start( ap, insn );
  782.  
  783.     /* make the faulty assumption that v and v2 exist */
  784.     s = va_arg( ap, char * );
  785.     v = va_arg( ap, int );
  786.     v2 = va_arg( ap, int );
  787. #endif
  788.  
  789.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  790.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  791.     asmop = SET_SRC (body);
  792.   else if (GET_CODE (body) == ASM_OPERANDS)
  793.     asmop = body;
  794.   else if (GET_CODE (body) == PARALLEL
  795.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  796.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  797.   else if (GET_CODE (body) == PARALLEL
  798.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  799.     asmop = XVECEXP (body, 0, 0);
  800.  
  801.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  802.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  803.  
  804.   error_with_file_and_line (filename, line, s, v, v2);
  805. #if defined (_MSDOS )
  806.     va_end( ap );
  807. #endif
  808. }
  809.  
  810. /* Report a warning at line LINE.
  811.    S and V are a string and an arg for `printf'.  */
  812.  
  813. #if ! defined( _MSDOS )
  814. void
  815. warning_with_file_and_line (file, line, s, v, v2)
  816.      char *file;
  817.      int line;
  818.      char *s;
  819.      int v;
  820.      int v2;
  821. #else
  822. void warning_with_file_and_line ( char * file, ... )
  823. #endif
  824. {
  825. #if defined (_MSDOS )
  826.     char *s;
  827.     int line, v, v2;
  828.     va_list ap;
  829.  
  830.     va_start( ap, file );
  831.  
  832.     /* make the faulty assumption that v and v2 exist */
  833.     line = va_arg( ap, int );
  834.     s = va_arg( ap, char * );
  835.     v = va_arg( ap, int );
  836.     v2 = va_arg( ap, int );
  837. #endif
  838.  
  839.   if (count_error (1) == 0)
  840.     return;
  841.  
  842.   report_error_function (file);
  843.  
  844.   if (file)
  845.     fprintf (stderr, "%s:%d: ", file, line);
  846.   else
  847.     fprintf (stderr, "%s: ", progname);
  848.  
  849.   fprintf (stderr, "warning: ");
  850.   fprintf (stderr, s, v, v2);
  851.   fprintf (stderr, "\n");
  852. #if defined (_MSDOS )
  853.     va_end( ap );
  854. #endif
  855. }
  856.  
  857. /* Report a warning at the current line number.
  858.    S and V are a string and an arg for `printf'.  */
  859.  
  860. #if ! defined( _MSDOS )
  861. void
  862. warning (s, v, v2)
  863.      char *s;
  864.      int v;            /* @@also used as pointer */
  865.      int v2;
  866. #else
  867. void warning ( char * s, ... )
  868. #endif
  869. {
  870. #if defined (_MSDOS )
  871.     int v, v2;
  872.     va_list ap;
  873.  
  874.     va_start( ap, s );
  875.  
  876.     /* make the faulty assumption that v and v2 exist */
  877.     v = va_arg( ap, int );
  878.     v2 = va_arg( ap, int );
  879. #endif
  880.   warning_with_file_and_line (input_filename, lineno, s, v, v2);
  881. #if defined (_MSDOS )
  882.     va_end( ap );
  883. #endif
  884. }
  885.  
  886. /* Report a warning at the declaration DECL.
  887.    S is string which uses %s to substitute the declaration name.
  888.    V is a second parameter that S can refer to.  */
  889.  
  890. #if ! defined ( _MSDOS )
  891. void
  892. warning_with_decl (decl, s, v)
  893.      tree decl;
  894.      char *s;
  895.      int v;
  896. #else
  897. void warning_with_decl ( tree decl,  ... )
  898. #endif
  899. {
  900. #if defined (_MSDOS )
  901.     char *s;
  902.     int v;
  903.     va_list ap;
  904.  
  905.     va_start( ap, decl );
  906.  
  907.     /* make the faulty assumption that v and v2 exist */
  908.     s = va_arg( ap, char * );
  909.     v = va_arg( ap, int );
  910. #endif
  911.  
  912.   if (count_error (1) == 0)
  913.     return;
  914.  
  915.   report_error_function (DECL_SOURCE_FILE (decl));
  916.  
  917.   fprintf (stderr, "%s:%d: ",
  918.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  919.  
  920.   fprintf (stderr, "warning: ");
  921.   if (DECL_PRINT_NAME (decl))
  922.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  923.   else if (DECL_NAME (decl))
  924.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  925.   else
  926.     fprintf (stderr, s, "((anonymous))", v);
  927.   fprintf (stderr, "\n");
  928. #if defined (_MSDOS )
  929.     va_end( ap );
  930. #endif
  931. }
  932.  
  933. /* Apologize for not implementing some feature.
  934.    S, V, and V2 are a string and args for `printf'.  */
  935.  
  936. #if ! defined( _MSDOS )
  937. void
  938. sorry (s, v, v2)
  939.      char *s;
  940.      int v, v2;
  941. #else
  942. void sorry ( char * s, ... )
  943. #endif
  944. {
  945. #if defined (_MSDOS )
  946.     int v, v2;
  947.     va_list ap;
  948.  
  949.     va_start( ap, s );
  950.  
  951.     /* make the faulty assumption that v and v2 exist */
  952.     v = va_arg( ap, int );
  953.     v2 = va_arg( ap, int );
  954. #endif
  955.  
  956.   sorrycount++;
  957.   if (input_filename)
  958.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  959.   else
  960.     fprintf (stderr, "%s: ", progname);
  961.  
  962.   fprintf (stderr, "sorry, not implemented: ");
  963.   fprintf (stderr, s, v, v2);
  964.   fprintf (stderr, "\n");
  965. #if defined (_MSDOS )
  966.     va_end( ap );
  967. #endif
  968. }
  969.  
  970. /* Apologize for not implementing some feature, then quit.
  971.    S, V, and V2 are a string and args for `printf'.  */
  972.  
  973. #if ! defined (_MSDOS )
  974. void
  975. really_sorry (s, v, v2)
  976.      char *s;
  977.      int v, v2;
  978. #else
  979. void really_sorry ( char * s, ... )
  980. #endif
  981. {
  982. #if defined (_MSDOS )
  983.     int v, v2;
  984.     va_list ap;
  985.  
  986.     va_start( ap, s );
  987.  
  988.     /* make the faulty assumption that v and v2 exist */
  989.     v = va_arg( ap, int );
  990.     v2 = va_arg( ap, int );
  991. #endif
  992.  
  993.   if (input_filename)
  994.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  995.   else
  996.     fprintf (stderr, "c++: ");
  997.  
  998.   fprintf (stderr, "sorry, not implemented: ");
  999.   fprintf (stderr, s, v, v2);
  1000.   fatal (" (fatal)\n");
  1001. #if defined (_MSDOS )
  1002.     va_end( ap );
  1003. #endif
  1004. }
  1005.  
  1006. /* More 'friendly' abort that prints the line and file.
  1007.    config.h can #define abort fancy_abort if you like that sort of thing.  */
  1008.  
  1009. void
  1010. fancy_abort ()
  1011. {
  1012.   fatal ("Internal gcc abort.");
  1013. }
  1014.  
  1015. /* When `malloc.c' is compiled with `rcheck' defined,
  1016.    it calls this function to report clobberage.  */
  1017.  
  1018. void
  1019. botch (s)
  1020. {
  1021.   abort ();
  1022. }
  1023.  
  1024. /* Same as `malloc' but report error if no memory available.  */
  1025.  
  1026. #if defined( _MSDOS )
  1027. void*
  1028. xmalloc (size)
  1029.      unsigned size;
  1030. {
  1031.   register void* value = malloc (size);
  1032.   if (value == NULL)
  1033.     fatal ("Virtual memory exhausted.");
  1034.   return value;
  1035. }
  1036. #else
  1037. int
  1038. xmalloc (size)
  1039.      unsigned size;
  1040. {
  1041.   register int value = (int) malloc (size);
  1042.   if (value == 0)
  1043.     fatal ("Virtual memory exhausted.");
  1044.   return value;
  1045. }
  1046. #endif
  1047.  
  1048. /* Same as `realloc' but report error if no memory available.  */
  1049.  
  1050. #if defined( _MSDOS )
  1051. void*
  1052. xrealloc (ptr, size)
  1053.      char *ptr;
  1054.      int size;
  1055. {
  1056.   void* result = realloc (ptr, size);
  1057.   if (NULL == result)
  1058.     fatal ("Virtual memory exhausted.");
  1059.   return result;
  1060. }
  1061. #else
  1062. int
  1063. xrealloc (ptr, size)
  1064.      char *ptr;
  1065.      int size;
  1066. {
  1067.   int result = realloc (ptr, size);
  1068.   if (!result)
  1069.     fatal ("Virtual memory exhausted.");
  1070.   return result;
  1071. }
  1072. #endif
  1073.  
  1074. /* Return the logarithm of X, base 2, considering X unsigned,
  1075.    if X is a power of 2.  Otherwise, returns -1.  */
  1076.  
  1077. int
  1078. exact_log2 (x)
  1079.      register unsigned int x;
  1080. {
  1081.   register int log = 0;
  1082.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  1083.     if (x == (1 << log))
  1084.       return log;
  1085.   return -1;
  1086. }
  1087.  
  1088. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  1089.    If X is 0, return -1.  */
  1090.  
  1091. int
  1092. floor_log2 (x)
  1093.      register unsigned int x;
  1094. {
  1095.   register int log = 0;
  1096.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  1097.     if ((x & ((-1) << log)) == 0)
  1098.       return log - 1;
  1099.   return HOST_BITS_PER_INT - 1;
  1100. }
  1101.  
  1102. int float_handled;
  1103. jmp_buf float_handler;
  1104.  
  1105. /* Specify where to longjmp to when a floating arithmetic error happens.
  1106.    If HANDLER is 0, it means don't handle the errors any more.  */
  1107.  
  1108. void
  1109. set_float_handler (handler)
  1110.      jmp_buf handler;
  1111. {
  1112.   float_handled = (handler != 0);
  1113.   if (handler)
  1114.     bcopy (handler, float_handler, sizeof (float_handler));
  1115. }
  1116.  
  1117. /* Signals actually come here.  */
  1118.  
  1119. static void
  1120. float_signal ()
  1121. {
  1122.   if (float_handled == 0)
  1123.     abort ();
  1124.   float_handled = 0;
  1125.   longjmp (float_handler, 1);
  1126. }
  1127.  
  1128. /* Handler for SIGPIPE.  */
  1129.  
  1130. static void
  1131. pipe_closed ()
  1132. {
  1133.   fatal ("output pipe has been closed");
  1134. }
  1135.  
  1136. /* Compile an entire file of output from cpp, named NAME.
  1137.    Write a file of assembly output and various debugging dumps.  */
  1138.  
  1139. static void
  1140. compile_file (name)
  1141.      char *name;
  1142. {
  1143.   tree globals;
  1144.   int start_time;
  1145.   int dump_base_name_length;
  1146.  
  1147.   int name_specified = name != 0;
  1148.  
  1149.   if (dump_base_name == 0)
  1150.     dump_base_name = name ? name : "gccdump";
  1151.   dump_base_name_length = strlen (dump_base_name);
  1152.  
  1153.   parse_time = 0;
  1154.   varconst_time = 0;
  1155.   integration_time = 0;
  1156.   jump_time = 0;
  1157.   cse_time = 0;
  1158.   loop_time = 0;
  1159.   flow_time = 0;
  1160.   combine_time = 0;
  1161.   local_alloc_time = 0;
  1162.   global_alloc_time = 0;
  1163.   dbr_sched_time = 0;
  1164.   final_time = 0;
  1165.   symout_time = 0;
  1166.   dump_time = 0;
  1167.  
  1168.   /* Open input file.  */
  1169.  
  1170.   if (name == 0 || !strcmp (name, "-"))
  1171.     {
  1172.       finput = stdin;
  1173.       name = "stdin";
  1174.     }
  1175.   else
  1176.     finput = fopen (name, "r");
  1177.   if (finput == 0)
  1178.     pfatal_with_name (name);
  1179.  
  1180.   /* Initialize data in various passes.  */
  1181.  
  1182.   init_tree ();
  1183.   init_lex ();
  1184.   init_rtl ();
  1185.   init_emit_once ();
  1186.   init_decl_processing ();
  1187.   init_optabs ();
  1188.  
  1189.   /* If rtl dump desired, open the output file.  */
  1190.   if (rtl_dump)
  1191.     {
  1192.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1193. #if defined( _MSDOS )
  1194.       strcpy (dumpname, "debug.rtl");
  1195. #else
  1196.       strcpy (dumpname, dump_base_name);
  1197.       strcat (dumpname, ".rtl");
  1198. #endif
  1199.       rtl_dump_file = fopen (dumpname, "w");
  1200.       if (rtl_dump_file == 0)
  1201.     pfatal_with_name (dumpname);
  1202.     }
  1203.  
  1204.   /* If jump_opt dump desired, open the output file.  */
  1205.   if (jump_opt_dump)
  1206.     {
  1207.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1208. #if defined( _MSDOS )
  1209.       strcpy (dumpname, "debug");
  1210.       strcat (dumpname, ".jmp");
  1211. #else
  1212.       strcpy (dumpname, dump_base_name);
  1213.       strcat (dumpname, ".jump");
  1214. #endif
  1215.       jump_opt_dump_file = fopen (dumpname, "w");
  1216.       if (jump_opt_dump_file == 0)
  1217.     pfatal_with_name (dumpname);
  1218.     }
  1219.  
  1220.   /* If cse dump desired, open the output file.  */
  1221.   if (cse_dump)
  1222.     {
  1223.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1224. #if defined( _MSDOS )
  1225.       strcpy (dumpname, "debug.cse");
  1226. #else
  1227.       strcpy (dumpname, dump_base_name);
  1228.       strcat (dumpname, ".cse");
  1229. #endif
  1230.       cse_dump_file = fopen (dumpname, "w");
  1231.       if (cse_dump_file == 0)
  1232.     pfatal_with_name (dumpname);
  1233.     }
  1234.  
  1235.   /* If loop dump desired, open the output file.  */
  1236.   if (loop_dump)
  1237.     {
  1238.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1239. #if defined( _MSDOS )
  1240.       strcpy (dumpname, "debug.lop");
  1241. #else
  1242.       strcpy (dumpname, dump_base_name);
  1243.       strcat (dumpname, ".loop");
  1244. #endif
  1245.       loop_dump_file = fopen (dumpname, "w");
  1246.       if (loop_dump_file == 0)
  1247.     pfatal_with_name (dumpname);
  1248.     }
  1249.  
  1250.   /* If flow dump desired, open the output file.  */
  1251.   if (flow_dump)
  1252.     {
  1253.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1254. #if defined( _MSDOS )
  1255.       strcpy (dumpname, "debug.flw");
  1256. #else
  1257.       strcpy (dumpname, dump_base_name);
  1258.       strcat (dumpname, ".flow");
  1259. #endif
  1260.       flow_dump_file = fopen (dumpname, "w");
  1261.       if (flow_dump_file == 0)
  1262.     pfatal_with_name (dumpname);
  1263.     }
  1264.  
  1265.   /* If combine dump desired, open the output file.  */
  1266.   if (combine_dump)
  1267.     {
  1268.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  1269. #if defined( _MSDOS )
  1270.       strcpy (dumpname, "debug.cmb");
  1271. #else
  1272.       strcpy (dumpname, dump_base_name);
  1273.       strcat (dumpname, ".combine");
  1274. #endif
  1275.       combine_dump_file = fopen (dumpname, "w");
  1276.       if (combine_dump_file == 0)
  1277.     pfatal_with_name (dumpname);
  1278.     }
  1279.  
  1280.   /* If local_reg dump desired, open the output file.  */
  1281.   if (local_reg_dump)
  1282.     {
  1283.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1284. #if defined( _MSDOS )
  1285.       strcpy (dumpname, "debug.lrg");
  1286. #else
  1287.       strcpy (dumpname, dump_base_name);
  1288.       strcat (dumpname, ".lreg");
  1289. #endif
  1290.       local_reg_dump_file = fopen (dumpname, "w");
  1291.       if (local_reg_dump_file == 0)
  1292.     pfatal_with_name (dumpname);
  1293.     }
  1294.  
  1295.   /* If global_reg dump desired, open the output file.  */
  1296.   if (global_reg_dump)
  1297.     {
  1298.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1299. #if defined( _MSDOS )
  1300.       strcpy (dumpname, "debug.grg");
  1301. #else
  1302.       strcpy (dumpname, dump_base_name);
  1303.       strcat (dumpname, ".greg");
  1304. #endif
  1305.       global_reg_dump_file = fopen (dumpname, "w");
  1306.       if (global_reg_dump_file == 0)
  1307.     pfatal_with_name (dumpname);
  1308.     }
  1309.  
  1310.   /* If jump2_opt dump desired, open the output file.  */
  1311.   if (jump2_opt_dump)
  1312.     {
  1313.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1314. #if defined( _MSDOS )
  1315.       strcpy (dumpname, "debug.jm2");
  1316. #else
  1317.       strcpy (dumpname, dump_base_name);
  1318.       strcat (dumpname, ".jump2");
  1319. #endif
  1320.       jump2_opt_dump_file = fopen (dumpname, "w");
  1321.       if (jump2_opt_dump_file == 0)
  1322.     pfatal_with_name (dumpname);
  1323.     }
  1324.  
  1325.   /* If dbr_sched dump desired, open the output file.  */
  1326.   if (dbr_sched_dump)
  1327.     {
  1328.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1329. #if defined( _MSDOS )
  1330.       strcpy (dumpname, "debug.dbr");
  1331. #else
  1332.       strcpy (dumpname, dump_base_name);
  1333.       strcat (dumpname, ".dbr");
  1334. #endif
  1335.       dbr_sched_dump_file = fopen (dumpname, "w");
  1336.       if (dbr_sched_dump_file == 0)
  1337.     pfatal_with_name (dumpname);
  1338.     }
  1339.  
  1340.   /* Open assembler code output file.  */
  1341.  
  1342.   if (! name_specified && asm_file_name == 0)
  1343.     asm_out_file = stdout;
  1344.   else
  1345.     {
  1346.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1347.       int len = strlen (dump_base_name);
  1348.       strcpy (dumpname, dump_base_name);
  1349.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1350.     dumpname[len - 2] = 0;
  1351.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1352.     dumpname[len - 2] = 0;
  1353.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1354.     dumpname[len - 3] = 0;
  1355.       strcat (dumpname, ".s");
  1356.       if (asm_file_name == 0)
  1357.     {
  1358.       asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  1359.       strcpy (asm_file_name, dumpname);
  1360.     }
  1361.       if (!strcmp (asm_file_name, "-"))
  1362.     asm_out_file = stdout;
  1363.       else
  1364.     asm_out_file = fopen (asm_file_name, "w");
  1365.       if (asm_out_file == 0)
  1366.     pfatal_with_name (asm_file_name);
  1367.     }
  1368.  
  1369.   input_filename = name;
  1370.  
  1371.   /* the beginning of the file is a new line; check for # */
  1372.   /* With luck, we discover the real source file's name from that
  1373.      and put it in input_filename.  */
  1374.   ungetc (check_newline (), finput);
  1375.  
  1376.   /* If the input doesn't start with a #line, use the input name
  1377.      as the official input file name.  */
  1378.   if (main_input_filename == 0)
  1379.     main_input_filename = name;
  1380.  
  1381.   /* Put an entry on the input file stack for the main input file.  */
  1382.   input_file_stack
  1383.     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  1384.   input_file_stack->next = 0;
  1385.   input_file_stack->name = input_filename;
  1386.  
  1387.   ASM_FILE_START (asm_out_file);
  1388.  
  1389.   /* Output something to inform GDB that this compilation was by GCC.  */
  1390. #ifndef ASM_IDENTIFY_GCC
  1391.   fprintf (asm_out_file, "gcc_compiled.:\n");
  1392. #else
  1393.   ASM_IDENTIFY_GCC (asm_out_file);
  1394. #endif
  1395.  
  1396.   /* If GDB symbol table desired, open the GDB symbol output file.  */
  1397.   if (write_symbols == GDB_DEBUG)
  1398.     {
  1399.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1400.       int len = strlen (dump_base_name);
  1401.       strcpy (dumpname, dump_base_name);
  1402.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1403.     dumpname[len - 2] = 0;
  1404.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1405.     dumpname[len - 2] = 0;
  1406.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1407.     dumpname[len - 3] = 0;
  1408.       strcat (dumpname, ".sym");
  1409.       if (sym_file_name == 0)
  1410.     sym_file_name = dumpname;
  1411.       symout_init (sym_file_name, asm_out_file, main_input_filename);
  1412.     }
  1413.  
  1414.   /* If dbx symbol table desired, initialize writing it
  1415.      and output the predefined types.  */
  1416. #ifdef DBX_DEBUGGING_INFO
  1417.   if (write_symbols == DBX_DEBUG)
  1418.     dbxout_init (asm_out_file, main_input_filename);
  1419. #endif
  1420. #ifdef SDB_DEBUGGING_INFO
  1421.   if (write_symbols == SDB_DEBUG)
  1422.     sdbout_init (asm_out_file, main_input_filename);
  1423. #endif
  1424.  
  1425.   /* Initialize yet another pass.  */
  1426.  
  1427.   init_final (main_input_filename);
  1428.  
  1429.   start_time = gettime ();
  1430.  
  1431.   /* Call the parser, which parses the entire file
  1432.      (calling rest_of_compilation for each function).  */
  1433.  
  1434.   yyparse ();
  1435.  
  1436.   /* Compilation is now finished except for writing
  1437.      what's left of the symbol table output.  */
  1438.  
  1439.   parse_time += gettime () - start_time;
  1440.  
  1441.   parse_time -= integration_time;
  1442.   parse_time -= varconst_time;
  1443.  
  1444.   globals = getdecls ();
  1445.  
  1446.   /* Really define vars that have had only a tentative definition.
  1447.      Really output inline functions that must actually be callable
  1448.      and have not been output so far.  */
  1449.  
  1450.   {
  1451.     tree decl;
  1452.     for (decl = globals; decl; decl = TREE_CHAIN (decl))
  1453.       {
  1454.     if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  1455.         && ! TREE_ASM_WRITTEN (decl))
  1456.       {
  1457.         /* Don't write out static consts, unless we needed
  1458.            to take their address for some reason.  */
  1459.         if (! TREE_READONLY (decl)
  1460.         || TREE_PUBLIC (decl)
  1461.         || TREE_ADDRESSABLE (decl))
  1462.           rest_of_decl_compilation (decl, 0, 1, 1);
  1463.         /* Otherwise maybe mention them just for the debugger.  */
  1464. #ifdef DBX_DEBUGGING_INFO
  1465.         else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
  1466.           TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1467. #endif
  1468. #ifdef SDB_DEBUGGING_INFO
  1469.         else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
  1470.           TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1471. #endif
  1472.       }
  1473.     if (TREE_CODE (decl) == FUNCTION_DECL
  1474.         && ! TREE_ASM_WRITTEN (decl)
  1475.         && DECL_INITIAL (decl) != 0
  1476.         && TREE_ADDRESSABLE (decl)
  1477.         && ! TREE_EXTERNAL (decl))
  1478.       output_inline_function (decl);
  1479.  
  1480.     /* Warn about any function declared static but not defined.  */
  1481.     if (warn_unused
  1482.         && TREE_CODE (decl) == FUNCTION_DECL
  1483.         && DECL_INITIAL (decl) == 0
  1484.         && TREE_EXTERNAL (decl)
  1485.         && ! TREE_PUBLIC (decl))
  1486.       warning_with_decl (decl, "`%s' declared but never defined");
  1487.     /* Warn about statics fns or vars defined but not used,
  1488.        but not about inline functions
  1489.        since unused inline statics is normal practice.  */
  1490.     if (warn_unused
  1491.         && (TREE_CODE (decl) == FUNCTION_DECL
  1492.         || TREE_CODE (decl) == VAR_DECL)
  1493.         && ! TREE_EXTERNAL (decl)
  1494.         && ! TREE_PUBLIC (decl)
  1495.         && ! TREE_USED (decl)
  1496.         && ! TREE_INLINE (decl)
  1497.         /* The TREE_USED bit for file-scope decls
  1498.            is kept in the identifier, to handle multiple
  1499.            external decls in different scopes.  */
  1500.         && ! TREE_USED (DECL_NAME (decl)))
  1501.       warning_with_decl (decl, "`%s' defined but not used");
  1502.       }
  1503.   }
  1504.  
  1505.   /* Do dbx symbols */
  1506. #ifdef DBX_DEBUGGING_INFO
  1507.   if (write_symbols == DBX_DEBUG)
  1508.     TIMEVAR (symout_time,
  1509.          {
  1510.            dbxout_tags (gettags ());
  1511.            dbxout_types (get_permanent_types ());
  1512.          });
  1513. #endif
  1514.  
  1515. #ifdef SDB_DEBUGGING_INFO
  1516.   if (write_symbols == SDB_DEBUG)
  1517.     TIMEVAR (symout_time,
  1518.          {
  1519.            sdbout_tags (gettags ());
  1520.            sdbout_types (get_permanent_types ());
  1521.          });
  1522. #endif
  1523.  
  1524.   /* Do gdb symbols */
  1525.   if (write_symbols == GDB_DEBUG)
  1526. #if defined( _MSDOS )
  1527.     TIMEVAR (symout_time,
  1528.          {
  1529.            struct stat statbuf;
  1530.            stat (main_input_filename, &statbuf);
  1531.            symout_types (get_permanent_types ());
  1532.            symout_top_blocks (globals, gettags ());
  1533.            symout_finish (name, statbuf.st_ctime);
  1534.          });
  1535. #else
  1536.     TIMEVAR (symout_time,
  1537.          {
  1538.            struct stat statbuf;
  1539.            fstat (fileno (finput), &statbuf);
  1540.            symout_types (get_permanent_types ());
  1541.            symout_top_blocks (globals, gettags ());
  1542.            symout_finish (name, statbuf.st_ctime);
  1543.          });
  1544. #endif
  1545. /* we don't do gdb format symbols. 
  1546.  
  1547.   /* Output some stuff at end of file if nec.  */
  1548.  
  1549.   end_final (main_input_filename);
  1550.  
  1551. #ifdef ASM_FILE_END
  1552.   ASM_FILE_END (asm_out_file);
  1553. #endif
  1554.  
  1555.   /* Close the dump files.  */
  1556.  
  1557.   if (rtl_dump)
  1558.     fclose (rtl_dump_file);
  1559.  
  1560.   if (jump_opt_dump)
  1561.     fclose (jump_opt_dump_file);
  1562.  
  1563.   if (cse_dump)
  1564.     fclose (cse_dump_file);
  1565.  
  1566.   if (loop_dump)
  1567.     fclose (loop_dump_file);
  1568.  
  1569.   if (flow_dump)
  1570.     fclose (flow_dump_file);
  1571.  
  1572.   if (combine_dump)
  1573.     {
  1574.       dump_combine_total_stats (combine_dump_file);
  1575.       fclose (combine_dump_file);
  1576.     }
  1577.  
  1578.   if (local_reg_dump)
  1579.     fclose (local_reg_dump_file);
  1580.  
  1581.   if (global_reg_dump)
  1582.     fclose (global_reg_dump_file);
  1583.  
  1584.   if (jump2_opt_dump)
  1585.     fclose (jump2_opt_dump_file);
  1586.  
  1587.   if (dbr_sched_dump)
  1588.     fclose (dbr_sched_dump_file);
  1589.  
  1590.   /* Close non-debugging input and output files.  Take special care to note
  1591.      whether fclose returns an error, since the pages might still be on the
  1592.      buffer chain while the file is open.  */
  1593.  
  1594.   fclose (finput);
  1595.  
  1596. #if defined( _MSDOS )
  1597.   fclose ( asm_out_file );
  1598. #else
  1599.   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
  1600.     fatal_io_error (asm_file_name);
  1601. #endif
  1602.  
  1603.   /* Print the times.  */
  1604.  
  1605.   if (! quiet_flag)
  1606.     {
  1607.       fprintf (stderr,"\n");
  1608.       print_time ("parse", parse_time);
  1609.       print_time ("integration", integration_time);
  1610.       print_time ("jump", jump_time);
  1611.       print_time ("cse", cse_time);
  1612.       print_time ("loop", loop_time);
  1613.       print_time ("flow", flow_time);
  1614.       print_time ("combine", combine_time);
  1615.       print_time ("local-alloc", local_alloc_time);
  1616.       print_time ("global-alloc", global_alloc_time);
  1617.       print_time ("dbranch", dbr_sched_time);
  1618.       print_time ("final", final_time);
  1619.       print_time ("varconst", varconst_time);
  1620.       print_time ("symout", symout_time);
  1621.       print_time ("dump", dump_time);
  1622.     }
  1623. }
  1624.  
  1625. /* This is called from finish_decl (within yyparse)
  1626.    for each declaration of a function or variable.
  1627.    This does nothing for automatic variables.
  1628.    Otherwise, it sets up the RTL and outputs any assembler code
  1629.    (label definition, storage allocation and initialization).
  1630.  
  1631.    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
  1632.    the assembler symbol name to be used.  TOP_LEVEL is nonzero
  1633.    if this declaration is not within a function.  */
  1634.  
  1635. void
  1636. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  1637.      tree decl;
  1638.      char *asmspec;
  1639.      int top_level;
  1640.      int at_end;
  1641. {
  1642. #if defined( DSP56000 ) || defined( DSP96000 )
  1643.     /* accomodate any run-time/load-time counter #pragmas. */
  1644.     push_counters ( decl );
  1645. #endif
  1646.   /* Declarations of variables, and of functions defined elsewhere.  */
  1647.  
  1648.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  1649.     TIMEVAR (varconst_time,
  1650.          {
  1651.            make_decl_rtl (decl, asmspec, top_level);
  1652.            /* Don't output anything
  1653.           when a tentative file-scope definition is seen.
  1654.           But at end of compilation, do output code for them.  */
  1655.            if (! (! at_end && top_level
  1656.               && (DECL_INITIAL (decl) == 0
  1657.               || DECL_INITIAL (decl) == error_mark_node)))
  1658.          assemble_variable (decl, top_level, write_symbols, at_end);
  1659.          });
  1660.   else if (TREE_REGDECL (decl) && asmspec != 0)
  1661.     {
  1662.       if (decode_reg_name (asmspec) >= 0)
  1663.     {
  1664.       DECL_RTL (decl) = 0;
  1665.       make_decl_rtl (decl, asmspec, top_level);
  1666.     }
  1667.       else
  1668.     error ("invalid register name `%s' for register variable", asmspec);
  1669.     }
  1670. #ifdef DBX_DEBUGGING_INFO
  1671.   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1672.     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1673. #endif
  1674. #ifdef SDB_DEBUGGING_INFO
  1675.   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1676.     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1677. #endif
  1678.  
  1679.   if (top_level)
  1680.     {
  1681.       if (write_symbols == GDB_DEBUG)
  1682.     {
  1683.       TIMEVAR (symout_time,
  1684.            {
  1685.              /* The initizations make types when they contain
  1686.             string constants.  The types are on the temporary
  1687.             obstack, so output them now before they go away.  */
  1688.              symout_types (get_temporary_types ());
  1689.            });
  1690.     }
  1691.       else
  1692.     /* Clean out the temporary type list, since the types will go away.  */
  1693.     get_temporary_types ();
  1694.     }
  1695. #if defined( DSP56000 ) || defined( DSP96000 )
  1696.     /* see start of fn. */
  1697.     pop_counters ( );
  1698. #endif
  1699. }
  1700.  
  1701. /* This is called from finish_function (within yyparse)
  1702.    after each top-level definition is parsed.
  1703.    It is supposed to compile that function or variable
  1704.    and output the assembler code for it.
  1705.    After we return, the tree storage is freed.  */
  1706.  
  1707. void
  1708. rest_of_compilation (decl)
  1709.      tree decl;
  1710. {
  1711.   register rtx insns;
  1712.   int start_time = gettime ();
  1713.   int tem;
  1714.  
  1715.   /* If we are reconsidering an inline function
  1716.      at the end of compilation, skip the stuff for making it inline.  */
  1717.  
  1718.   if (DECL_SAVED_INSNS (decl) == 0)
  1719.     {
  1720.  
  1721.       /* If requested, consider whether to make this function inline.  */
  1722.       if (flag_inline_functions || TREE_INLINE (decl))
  1723.     {
  1724.       TIMEVAR (integration_time,
  1725.            {
  1726.              int specd = TREE_INLINE (decl);
  1727.              char *lose = function_cannot_inline_p (decl);
  1728.              if (lose != 0 && specd)
  1729.                warning_with_decl (decl, lose);
  1730.              if (lose == 0)
  1731.                save_for_inline (decl);
  1732.              else
  1733.                TREE_INLINE (decl) = 0;
  1734.            });
  1735.     }
  1736.  
  1737.       insns = get_insns ();
  1738.  
  1739.       /* Dump the rtl code if we are dumping rtl.  */
  1740.  
  1741.       if (rtl_dump)
  1742.     TIMEVAR (dump_time,
  1743.          {
  1744.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  1745.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1746.            if (DECL_SAVED_INSNS (decl))
  1747.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  1748.            print_rtl (rtl_dump_file, insns);
  1749.            fflush (rtl_dump_file);
  1750.          });
  1751.  
  1752.       /* If function is inline, and we don't yet know whether to
  1753.      compile it by itself, defer decision till end of compilation.
  1754.      finish_compilation will call rest_of_compilation again
  1755.      for those functions that need to be output.  */
  1756.  
  1757.       if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
  1758.         && ! flag_keep_inline_functions)
  1759.        || TREE_EXTERNAL (decl))
  1760.       && TREE_INLINE (decl))
  1761.     goto exit_rest_of_compilation;
  1762.     }
  1763.  
  1764.   if (rtl_dump_and_exit || flag_syntax_only)
  1765.     {
  1766.       get_temporary_types ();
  1767.       goto exit_rest_of_compilation;
  1768.     }
  1769.  
  1770.   TREE_ASM_WRITTEN (decl) = 1;
  1771.  
  1772.   insns = get_insns ();
  1773.  
  1774.   /* Copy any shared structure that should not be shared.  */
  1775.  
  1776.   unshare_all_rtl (insns);
  1777.  
  1778.   /* See if we have allocated stack slots that are not directly addressable.
  1779.      If so, scan all the insns and create explicit address computation
  1780.      for all references to such slots.  */
  1781. /*   fixup_stack_slots (); */
  1782.  
  1783.   /* Do jump optimization the first time, if -opt.
  1784.      Also do it if -W, but in that case it doesn't change the rtl code,
  1785.      it only computes whether control can drop off the end of the function.  */
  1786.  
  1787.   if (optimize || extra_warnings || warn_return_type
  1788.       /* If function is `volatile', we should warn if it tries to return.  */
  1789.       || TREE_THIS_VOLATILE (decl))
  1790.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1791.  
  1792.   /* Dump rtl code after jump, if we are doing that.  */
  1793.  
  1794.   if (jump_opt_dump)
  1795.     TIMEVAR (dump_time,
  1796.          {
  1797.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  1798.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1799.            print_rtl (jump_opt_dump_file, insns);
  1800.            fflush (jump_opt_dump_file);
  1801.          });
  1802.  
  1803.   /* Perform common subexpression elimination.
  1804.      Nonzero value from `cse_main' means that jumps were simplified
  1805.      and some code may now be unreachable, so do
  1806.      jump optimization again.  */
  1807.  
  1808.   if (optimize)
  1809.     {
  1810.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1811.  
  1812.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
  1813.  
  1814.       if (tem)
  1815.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1816.     }
  1817.  
  1818.   /* Dump rtl code after cse, if we are doing that.  */
  1819.  
  1820.   if (cse_dump)
  1821.     TIMEVAR (dump_time,
  1822.          {
  1823.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  1824.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1825.            print_rtl (cse_dump_file, insns);
  1826.            fflush (cse_dump_file);
  1827.          });
  1828.  
  1829.   if (loop_dump)
  1830.     TIMEVAR (dump_time,
  1831.          {
  1832.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  1833.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1834.          });
  1835.  
  1836.   /* Move constant computations out of loops.  */
  1837.  
  1838.   if (optimize)
  1839.     {
  1840.       TIMEVAR (loop_time,
  1841.            {
  1842.          reg_scan (insns, max_reg_num (), 1);
  1843.          loop_optimize (insns, loop_dump ? loop_dump_file : 0);
  1844.            });
  1845.     }
  1846.  
  1847. #if defined( DSP96000 ) || defined( DSP56000 )
  1848.   /* there are situations where blocks have been merged or rearranged
  1849.    * by the loop optimizer. this opens up new opportunities for constant
  1850.    * propagation and possibly jump elimination. we may have found a single
  1851.    * iteration loop as well.
  1852.    */
  1853.  
  1854.   if ( optimize && ( TARGET_DO_LOOP_GENERATION ))
  1855.   {
  1856.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1857.       TIMEVAR (cse_time, cse_main (insns, max_reg_num ()));
  1858.       TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1859.   }
  1860. #endif
  1861. #if defined( DSP56000 )
  1862.   /* constant folding can leave modified "wierdo" rtl insns around, 
  1863.      which might be replaced by a more conventional insn. for example,
  1864.      the div template, assuming that the div result was statically 
  1865.      computed in cse, might look like this:
  1866.      
  1867.      ( parallel [ ( set ( reg ) ( const_int ))
  1868.                   ( clobber ( reg ))
  1869.           ( clobber ( reg )) ] ).
  1870.      
  1871.      this can be replaced by:
  1872.  
  1873.      ( set ( reg ) ( const_int )),
  1874.      
  1875.       thereby avoiding two needless register kills. */
  1876.      
  1877.   TIMEVAR (cse_time, simplify_cse_victims ( insns ));
  1878.  
  1879. #endif
  1880.   /* Dump rtl code after loop opt, if we are doing that.  */
  1881.  
  1882.   if (loop_dump)
  1883.     TIMEVAR (dump_time,
  1884.          {
  1885.            print_rtl (loop_dump_file, insns);
  1886.            fflush (loop_dump_file);
  1887.          });
  1888.  
  1889.   /* Now we choose between stupid (pcc-like) register allocation
  1890.      (if we got the -noreg switch and not -opt)
  1891.      and smart register allocation.  */
  1892.  
  1893.   if (optimize)        /* Stupid allocation probably won't work */
  1894.     obey_regdecls = 0;    /* if optimizations being done.  */
  1895.  
  1896.   regclass_init ();
  1897.  
  1898.   /* Print function header into flow dump now
  1899.      because doing the flow analysis makes some of the dump.  */
  1900.  
  1901.   if (flow_dump)
  1902.     TIMEVAR (dump_time,
  1903.          {
  1904.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  1905.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1906.          });
  1907.  
  1908.   if (obey_regdecls)
  1909.     {
  1910.       TIMEVAR (flow_time,
  1911.            {
  1912.          regclass (insns, max_reg_num ());
  1913.          stupid_life_analysis (insns, max_reg_num (),
  1914.                        flow_dump_file);
  1915.            });
  1916.     }
  1917.   else
  1918.     {
  1919.       /* Do control and data flow analysis,
  1920.      and write some of the results to dump file.  */
  1921.  
  1922.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  1923.                      flow_dump_file));
  1924.       if (extra_warnings)
  1925.     uninitialized_vars_warning (DECL_INITIAL (decl));
  1926.     }
  1927.  
  1928.   /* Dump rtl after flow analysis.  */
  1929.  
  1930.   if (flow_dump)
  1931.     TIMEVAR (dump_time,
  1932.          {
  1933.            print_rtl (flow_dump_file, insns);
  1934.            fflush (flow_dump_file);
  1935.          });
  1936.  
  1937.   /* If -opt, try combining insns through substitution.  */
  1938.  
  1939.   if (optimize)
  1940.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  1941.  
  1942.   /* Dump rtl code after insn combination.  */
  1943.  
  1944.   if (combine_dump)
  1945.     TIMEVAR (dump_time,
  1946.          {
  1947.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  1948.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1949.            dump_combine_stats (combine_dump_file);
  1950.            print_rtl (combine_dump_file, insns);
  1951.            fflush (combine_dump_file);
  1952.          });
  1953.  
  1954.   /* Unless we did stupid register allocation,
  1955.      allocate pseudo-regs that are used only within 1 basic block.  */
  1956.  
  1957. #if defined( DSP56000 )
  1958. /* at this point, we have to sort all of the compares into signed and
  1959.    unsigned. */
  1960.   TIMEVAR ( local_alloc_time,
  1961.        {
  1962.        sort_compares ( insns );
  1963.        } );
  1964. #endif
  1965.   if (!obey_regdecls)
  1966.     TIMEVAR (local_alloc_time,
  1967.          {
  1968.            regclass (insns, max_reg_num ());
  1969.            local_alloc ();
  1970.          });
  1971.  
  1972.   /* Dump rtl code after allocating regs within basic blocks.  */
  1973.  
  1974.   if (local_reg_dump)
  1975.     TIMEVAR (dump_time,
  1976.          {
  1977.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  1978.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1979.            dump_flow_info (local_reg_dump_file);
  1980.            dump_local_alloc (local_reg_dump_file);
  1981.            print_rtl (local_reg_dump_file, insns);
  1982.            fflush (local_reg_dump_file);
  1983.          });
  1984.  
  1985.   if (global_reg_dump)
  1986.     TIMEVAR (dump_time,
  1987.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  1988.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  1989.  
  1990.   /* Unless we did stupid register allocation,
  1991.      allocate remaining pseudo-regs, then do the reload pass
  1992.      fixing up any insns that are invalid.  */
  1993. #if defined( DSP56000 ) || defined( DSP96000 )
  1994.   TIMEVAR (global_alloc_time,
  1995.        {
  1996.          if (!obey_regdecls)
  1997.          ( global_alloc ( global_reg_dump ? global_reg_dump_file : 0 ),
  1998.           (( TARGET_RELOAD_CLEANUP ) ? cleanup_reloads( insns ) : 0 ));
  1999.          else
  2000.            reload (insns, 0,
  2001.                global_reg_dump ? global_reg_dump_file : 0);
  2002.        });
  2003. #else
  2004.   TIMEVAR (global_alloc_time,
  2005.        {
  2006.          if (!obey_regdecls)
  2007.            global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  2008.          else
  2009.            reload (insns, 0,
  2010.                global_reg_dump ? global_reg_dump_file : 0);
  2011.        });
  2012.  
  2013. #endif
  2014.  
  2015.   if (global_reg_dump)
  2016.     TIMEVAR (dump_time,
  2017.          {
  2018.            dump_global_regs (global_reg_dump_file);
  2019.            print_rtl (global_reg_dump_file, insns);
  2020.            fflush (global_reg_dump_file);
  2021.          });
  2022.  
  2023.   rtx_equal_function_value_matters = 1;
  2024.   reload_completed = 1;
  2025.  
  2026.   /* One more attempt to remove jumps to .+1
  2027.      left by dead-store-elimination.
  2028.      Also do cross-jumping this time
  2029.      and delete no-op move insns.  */
  2030.  
  2031.   if (optimize)
  2032.     {
  2033.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  2034.     }
  2035.  
  2036.   /* Dump rtl code after jump, if we are doing that.  */
  2037.  
  2038.   if (jump2_opt_dump)
  2039.     TIMEVAR (dump_time,
  2040.          {
  2041.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  2042.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  2043.            print_rtl (jump2_opt_dump_file, insns);
  2044.            fflush (jump2_opt_dump_file);
  2045.          });
  2046.  
  2047.   /* If a scheduling pass for delayed branches is to be done,
  2048.      call the scheduling code. */
  2049.  
  2050. #ifdef HAVE_DELAYED_BRANCH
  2051.   if (optimize && flag_delayed_branch)
  2052.     {
  2053.       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
  2054.       if (dbr_sched_dump)
  2055.     {
  2056.       TIMEVAR (dump_time,
  2057.          {
  2058.            fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
  2059.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  2060.            print_rtl (dbr_sched_dump_file, insns);
  2061.            fflush (dbr_sched_dump_file);
  2062.          });
  2063.     }
  2064.     }
  2065. #endif
  2066.  
  2067. #if defined( DSP56000 )
  2068.   /* mpy(and mac) shapes require a move/shift sequence to normalize output(and
  2069.      input) data. here, we pass through the insns and detect those macs whose 
  2070.      additive inputs are mac/mpy outputs. we mark these insn pairs as not 
  2071.      needing the normalization shifts between them. For example:
  2072.  
  2073.     mpy    x0,y1,a
  2074.     asr    a
  2075.     move    a0,a
  2076.     move    a,a0
  2077.     asl    a
  2078.     mac    +x1,y0,a
  2079.     asr    a
  2080.     move    a0,a
  2081.  
  2082.      becomes:
  2083.  
  2084.     mpy    x0,y1,a
  2085.     mac    +x1,y0,a
  2086.     asr    a
  2087.     move    a0,a
  2088.  
  2089.      and so on ... */
  2090.  
  2091.   if ( TARGET_NORMALIZATION_REDUCTION )
  2092.   {
  2093.       TIMEVAR (combine_time, reduce_norm_freq ( insns ));
  2094.   }
  2095. #endif
  2096.  
  2097.   /* Now turn the rtl into assembler code.  */
  2098. #if defined( DSP56000 ) || defined( DSP96000 )
  2099.   TIMEVAR (final_time,
  2100.        {
  2101.          /* accomodate any run-time/load-time counter #pragmas. */
  2102.          push_counters (decl);
  2103.          assemble_function (decl);
  2104.          final_start_function (insns, asm_out_file,
  2105.                    write_symbols, optimize);
  2106.          final (insns, asm_out_file,
  2107.             write_symbols, optimize, 0);
  2108.          final_end_function (insns, asm_out_file,
  2109.                  write_symbols, optimize);
  2110.          fflush (asm_out_file);
  2111.          pop_counters ( );
  2112.        });
  2113. #else
  2114.  
  2115.   TIMEVAR (final_time,
  2116.        {
  2117.          assemble_function (decl);
  2118.          final_start_function (insns, asm_out_file,
  2119.                    write_symbols, optimize);
  2120.          final (insns, asm_out_file,
  2121.             write_symbols, optimize, 0);
  2122.          final_end_function (insns, asm_out_file,
  2123.                  write_symbols, optimize);
  2124.          fflush (asm_out_file);
  2125.        });
  2126. #endif
  2127.  
  2128.   /* Write GDB symbols if requested */
  2129.  
  2130.   if (write_symbols == GDB_DEBUG)
  2131.     {
  2132.       TIMEVAR (symout_time,
  2133.            {
  2134.          symout_types (get_permanent_types ());
  2135.          symout_types (get_temporary_types ());
  2136.  
  2137.          DECL_BLOCK_SYMTAB_ADDRESS (decl)
  2138.            = symout_function (DECL_INITIAL (decl),
  2139.                       DECL_ARGUMENTS (decl), 0);
  2140.          symout_function_end ();
  2141.            });
  2142.     }
  2143.   else
  2144.     get_temporary_types ();
  2145.  
  2146.   /* Write DBX symbols if requested */
  2147.  
  2148. #ifdef DBX_DEBUGGING_INFO
  2149.   if (write_symbols == DBX_DEBUG)
  2150.     TIMEVAR (symout_time, dbxout_function (decl));
  2151. #endif
  2152.  
  2153.  exit_rest_of_compilation:
  2154.  
  2155.   rtx_equal_function_value_matters = 0;
  2156.   reload_completed = 0;
  2157.  
  2158.   /* Clear out the real_constant_chain before some of the rtx's
  2159.      it runs through become garbage.  */
  2160.  
  2161.   clear_const_double_mem ();
  2162.  
  2163.   /* The parsing time is all the time spent in yyparse
  2164.      *except* what is spent in this function.  */
  2165.  
  2166. #if defined( DSP96000 ) || defined( DSP56000 )
  2167.   /* reset to "no information" for the next function. */
  2168.   current_func_info = FUNC_NO_INFO;
  2169. #endif
  2170.   parse_time -= gettime () - start_time;
  2171. }
  2172.  
  2173. /* Entry point of cc1.  Decode command args, then call compile_file.
  2174.    Exit code is 35 if can't open files, 34 if fatal error,
  2175.    33 if had nonfatal errors, else success.  */
  2176.  
  2177.  
  2178. #if defined ( _MSDOS )
  2179. /* the fabulous MSDOS forces use to allocate a fake argv incase we must
  2180.    reallocate argv later. */
  2181. int
  2182. main (argc, argv, envp)
  2183.      int argc;
  2184.      char **argv;
  2185.      char **envp;
  2186. {
  2187.     int i = 0;
  2188.     char **fake_argv;
  2189.     
  2190.     fake_argv = (char **) xmalloc( sizeof( char* ) * ( argc + 1 ) );
  2191.     while ( argv[ i ] != NULL )
  2192.     {
  2193.     fake_argv[ i ] = (char*) xmalloc ( sizeof( char ) * ( strlen( argv[ i ] ) + 1 ) );
  2194.     strcpy( fake_argv[ i ], argv[ i ] );
  2195.     i ++ ;
  2196.     }
  2197.     
  2198.     fake_main( argc, fake_argv, envp );
  2199. }
  2200.  
  2201. fake_main (argc, argv, envp)
  2202.      int argc;
  2203.      char **argv;
  2204.      char **envp;
  2205. {
  2206. #else
  2207. int
  2208. main (argc, argv, envp)
  2209.      int argc;
  2210.      char **argv;
  2211.      char **envp;
  2212. {
  2213. #endif
  2214.   register int i;
  2215.   char *filename = 0;
  2216.   int print_mem_flag = 0;
  2217.   char *p;
  2218.  
  2219. #if defined( DSP56000 ) || defined( DSP96000 )
  2220.   extend_argv( &argc, &argv );
  2221. #endif
  2222.  
  2223.   /* save in case md file wants to emit args as a comment.  */
  2224.   save_argc = argc;
  2225.   save_argv = argv;
  2226.  
  2227.   p = argv[0] + strlen (argv[0]);
  2228.   while (p != argv[0] && p[-1] != '/') --p;
  2229.   progname = p;
  2230.  
  2231. #ifdef RLIMIT_STACK
  2232.   /* Get rid of any avoidable limit on stack size.  */
  2233.   {
  2234.     struct rlimit rlim;
  2235.  
  2236.     /* Set the stack limit huge so that alloca does not fail. */
  2237.     getrlimit (RLIMIT_STACK, &rlim);
  2238.     rlim.rlim_cur = rlim.rlim_max;
  2239.     setrlimit (RLIMIT_STACK, &rlim);
  2240.   }
  2241. #endif /* RLIMIT_STACK */
  2242.  
  2243. #if ! defined( _MSDOS )
  2244.   signal (SIGFPE, float_signal);
  2245.  
  2246.   signal (SIGPIPE, pipe_closed);
  2247. #endif
  2248.  
  2249.   /* Initialize whether `char' is signed.  */
  2250.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  2251. #ifdef DEFAULT_SHORT_ENUMS
  2252.   /* Initialize how much space enums occupy, by default.  */
  2253.   flag_short_enums = DEFAULT_SHORT_ENUMS;
  2254. #endif
  2255.  
  2256.   /* This is zeroed by -O.  */
  2257.   obey_regdecls = 1;
  2258.  
  2259.   /* Initialize register usage now so switches may override.  */
  2260.   init_reg_sets ();
  2261.  
  2262.   target_flags = 0;
  2263.   set_target_switch ("");
  2264.  
  2265.   for (i = 1; i < argc; i++)
  2266.     if (argv[i][0] == '-' && argv[i][1] != 0)
  2267.       {
  2268.     register char *str = argv[i] + 1;
  2269.     if (str[0] == 'Y')
  2270.       str++;
  2271.  
  2272.     if (str[0] == 'm')
  2273.       set_target_switch (&str[1]);
  2274.     else if (!strcmp (str, "dumpbase"))
  2275.       {
  2276.         dump_base_name = argv[++i];
  2277.       }
  2278.     else if (str[0] == 'd')
  2279.       {
  2280.         register char *p = &str[1];
  2281.         while (*p)
  2282.           switch (*p++)
  2283.         {
  2284.         case 'c':
  2285.           combine_dump = 1;
  2286.           break;
  2287.         case 'd':
  2288.           dbr_sched_dump = 1;
  2289.           break;
  2290.         case 'f':
  2291.           flow_dump = 1;
  2292.           break;
  2293.         case 'g':
  2294.           global_reg_dump = 1;
  2295.           break;
  2296.         case 'j':
  2297.           jump_opt_dump = 1;
  2298.           break;
  2299.         case 'J':
  2300.           jump2_opt_dump = 1;
  2301.           break;
  2302.         case 'l':
  2303.           local_reg_dump = 1;
  2304.           break;
  2305.         case 'L':
  2306.           loop_dump = 1;
  2307.           break;
  2308.         case 'm':
  2309.           print_mem_flag = 1;
  2310.           break;
  2311.         case 'r':
  2312.           rtl_dump = 1;
  2313.           break;
  2314.         case 's':
  2315.           cse_dump = 1;
  2316.           break;
  2317.         case 'y':
  2318.           yydebug = 1;
  2319.           break;
  2320.         }
  2321.       }
  2322.     else if (str[0] == 'f')
  2323.       {
  2324.         int j;
  2325.         register char *p = &str[1];
  2326.         int found = 0;
  2327.  
  2328.         /* Some kind of -f option.
  2329.            P's value is the option sans `-f'.
  2330.            Search for it in the table of options.  */
  2331.  
  2332.         for (j = 0;
  2333.          !found && j < sizeof (f_options) / sizeof (f_options[0]);
  2334.          j++)
  2335.           {
  2336.         if (!strcmp (p, f_options[j].string))
  2337.           {
  2338.             *f_options[j].variable = f_options[j].on_value;
  2339.             /* A goto here would be cleaner,
  2340.                but breaks the vax pcc.  */
  2341.             found = 1;
  2342.           }
  2343.         if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  2344.             && ! strcmp (p+3, f_options[j].string))
  2345.           {
  2346.             *f_options[j].variable = ! f_options[j].on_value;
  2347.             found = 1;
  2348.           }
  2349.           }
  2350.  
  2351.         if (found)
  2352.           ;
  2353.         else if (!strncmp (p, "fixed-", 6))
  2354.           fix_register (&p[6], 1, 1);
  2355.         else if (!strncmp (p, "call-used-", 10))
  2356.           fix_register (&p[10], 0, 1);
  2357.         else if (!strncmp (p, "call-saved-", 11))
  2358.           fix_register (&p[11], 0, 0);
  2359.         else if (! lang_decode_option (argv[i]))
  2360.           error ("Invalid option `%s'", argv[i]);
  2361.       }
  2362.     else if (!strcmp (str, "noreg"))
  2363.       ;
  2364.     else if (!strcmp (str, "opt"))
  2365.       optimize = 1, obey_regdecls = 0;
  2366.     else if (!strcmp (str, "O"))
  2367.       optimize = 1, obey_regdecls = 0;
  2368.     else if (!strcmp (str, "pedantic"))
  2369.       pedantic = 1;
  2370.     else if (lang_decode_option (argv[i]))
  2371.       ;
  2372.     else if (!strcmp (str, "quiet"))
  2373.       quiet_flag = 1;
  2374.     else if (!strcmp (str, "version"))
  2375.       {
  2376.         extern char *version_string, *language_string;
  2377.         fprintf (stderr, "%s version %s", language_string, version_string);
  2378. #ifdef TARGET_VERSION
  2379.         TARGET_VERSION;
  2380. #endif
  2381. #ifdef __GNUC__
  2382. #ifndef __VERSION__
  2383. #define __VERSION__ "[unknown]"
  2384. #endif
  2385.         fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
  2386. #else
  2387. #if defined( __WATCOMC__ )
  2388.         fprintf (stderr, " compiled by WATCOM C.\n");
  2389. #else
  2390.         fprintf (stderr, " compiled by CC.\n");
  2391. #endif
  2392. #endif
  2393.         print_target_switch_defaults ();
  2394.       }
  2395.     else if (!strcmp (str, "w"))
  2396.       inhibit_warnings = 1;
  2397.     else if (!strcmp (str, "W"))
  2398.       extra_warnings = 1;
  2399.     else if (!strcmp (str, "Wunused"))
  2400.       warn_unused = 1;
  2401.     else if (!strcmp (str, "Wshadow"))
  2402.       warn_shadow = 1;
  2403.     else if (!strcmp (str, "Wswitch"))
  2404.       warn_switch = 1;
  2405.     else if (!strncmp (str, "Wid-clash-", 10))
  2406.       {
  2407.         char *endp = str + 10;
  2408.  
  2409.         while (*endp)
  2410.           {
  2411.         if (*endp >= '0' && *endp <= '9')
  2412.           endp++;
  2413.         else
  2414.           error ("Invalid option `%s'", argv[i]);
  2415.           }
  2416.         warn_id_clash = 1;
  2417.         id_clash_len = atoi (str + 10);
  2418.       }
  2419.     else if (!strcmp (str, "p"))
  2420.       profile_flag = 1;
  2421.     else if (!strcmp (str, "a"))
  2422.       {
  2423. #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
  2424.         warning ("`-a' option (basic block profile) not supported");
  2425. #else
  2426.         profile_block_flag = 1;
  2427. #endif
  2428.       }
  2429.     else if (!strcmp (str, "gg"))
  2430.       write_symbols = GDB_DEBUG;
  2431. #ifdef DBX_DEBUGGING_INFO
  2432.     else if (!strcmp (str, "g0"))
  2433.       write_symbols = DBX_DEBUG;
  2434.     else if (!strcmp (str, "G0"))
  2435.       write_symbols = DBX_DEBUG;
  2436.     else if (!strcmp (str, "g"))
  2437.       {
  2438.         write_symbols = DBX_DEBUG;
  2439.         use_gdb_dbx_extensions = 1;
  2440.       }
  2441.     else if (!strcmp (str, "G"))
  2442.       {
  2443.         write_symbols = DBX_DEBUG;
  2444.         use_gdb_dbx_extensions = 1;
  2445.       }
  2446. #endif
  2447. #ifdef SDB_DEBUGGING_INFO
  2448.     else if (!strcmp (str, "g"))
  2449.       write_symbols = SDB_DEBUG;
  2450.     else if (!strcmp (str, "G"))
  2451.       write_symbols = SDB_DEBUG;
  2452.     else if (!strcmp (str, "g0"))
  2453.       write_symbols = SDB_DEBUG;
  2454.     else if (!strcmp (str, "G0"))
  2455.       write_symbols = SDB_DEBUG;
  2456. #endif
  2457.     else if (!strcmp (str, "symout"))
  2458.       {
  2459.         if (write_symbols == NO_DEBUG)
  2460.           write_symbols = GDB_DEBUG;
  2461.         sym_file_name = argv[++i];
  2462.       }
  2463.     else if (!strcmp (str, "o"))
  2464.       {
  2465.         asm_file_name = argv[++i];
  2466.       }
  2467.     else
  2468.       error ("Invalid option `%s'", argv[i]);
  2469.       }
  2470.     else
  2471.       filename = argv[i];
  2472.  
  2473. #ifdef OVERRIDE_OPTIONS
  2474.   /* Some machines may reject certain combinations of options.  */
  2475.   OVERRIDE_OPTIONS;
  2476. #endif
  2477.  
  2478. #if defined( DSP56000 )
  2479.   if ( TARGET_X_MEMORY )
  2480.   {
  2481.       mem_space = 'x';
  2482.       memory_model = 'x';
  2483.       mode_size[ (int) DFmode ] = 6;
  2484.       mode_size[ (int) SFmode ] = 6;
  2485.   }
  2486.   else if ( TARGET_L_MEMORY )
  2487.   {
  2488.       mem_space = 'y';
  2489.       memory_model = 'l';
  2490.       mode_size[ (int) DFmode ] = 3;
  2491.       mode_size[ (int) SFmode ] = 3;
  2492.   }
  2493.   else /* default model */
  2494.   {
  2495.       mem_space = 'y';
  2496.       memory_model = 'y';
  2497.       mode_size[ (int) DFmode ] = 6;
  2498.       mode_size[ (int) SFmode ] = 6;
  2499.   }
  2500. #endif
  2501.  
  2502. #if defined( DSP96000 )
  2503.   if ( TARGET_X_MEMORY )
  2504.   {
  2505.       mem_space = 'x';
  2506.       memory_model = 'x';
  2507.       mode_size[ (int) DFmode ] = 2;
  2508.   }
  2509.   else if ( TARGET_Y_MEMORY )
  2510.   {
  2511.       mem_space = 'y';
  2512.       memory_model = 'y';
  2513.       mode_size[ (int) DFmode ] = 2;
  2514.   }
  2515.   else /* default model */
  2516.   {
  2517.       mem_space = 'y';
  2518.       memory_model = 'l';
  2519.       mode_size[ (int) DFmode ] = 1;
  2520.   }
  2521. #endif
  2522.  
  2523.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  2524.   init_reg_sets_1 ();
  2525.  
  2526.   compile_file (filename);
  2527.  
  2528. #if ! defined( _MSDOS )
  2529. #ifndef USG
  2530. #ifndef VMS
  2531.   if (print_mem_flag)
  2532.     {
  2533.       extern char **environ;
  2534.       char *lim = (char *) sbrk (0);
  2535.  
  2536.       fprintf (stderr, "Data size %d.\n",
  2537.            (int) lim - (int) &environ);
  2538.       fflush (stderr);
  2539.  
  2540.       system ("ps v");
  2541.     }
  2542. #endif /* not VMS */
  2543. #endif /* not USG */
  2544. #endif
  2545.  
  2546.   if (errorcount)
  2547.     exit (FATAL_EXIT_CODE);
  2548.   if (sorrycount)
  2549.     exit (FATAL_EXIT_CODE);
  2550.   exit (SUCCESS_EXIT_CODE);
  2551.   return 34;
  2552. }
  2553.  
  2554. /* Decode -m switches.  */
  2555.  
  2556. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  2557.    and which bits in `target_switches' it should set or clear.
  2558.    If VALUE is positive, it is bits to set.
  2559.    If VALUE is negative, -VALUE is bits to clear.
  2560.    (The sign bit is not used so there is no confusion.)  */
  2561.  
  2562. struct {char *name; int value;} target_switches []
  2563.   = TARGET_SWITCHES;
  2564.  
  2565. /* Decode the switch -mNAME.  */
  2566.  
  2567. void
  2568. set_target_switch (name)
  2569.      char *name;
  2570. {
  2571.   register int j;
  2572.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2573.     if (!strcmp (target_switches[j].name, name))
  2574.       {
  2575.     if (target_switches[j].value < 0)
  2576.       target_flags &= ~-target_switches[j].value;
  2577.     else
  2578.       target_flags |= target_switches[j].value;
  2579.     return;
  2580.       }
  2581.   error ("Invalid option `%s'", name);
  2582. }
  2583.  
  2584. /* Print default target switches for -version.  */
  2585.  
  2586. void
  2587. print_target_switch_defaults ()
  2588. {
  2589.   register int j;
  2590.   register int mask = TARGET_DEFAULT;
  2591.   fprintf (stderr, "default target switches:");
  2592.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2593.     if (target_switches[j].name[0] != '\0'
  2594.     && target_switches[j].value > 0
  2595.     && (target_switches[j].value & mask) == target_switches[j].value)
  2596.  
  2597.       fprintf (stderr, " -m%s", target_switches[j].name);
  2598.  
  2599.   fprintf (stderr, "\n");
  2600. }
  2601. #if defined( __HIGHC__ ) || defined( _INTELC32_ ) || defined( __WATCOMC__ )
  2602. int
  2603. bcopy ( b1, b2, length )
  2604.     char* b1, * b2;
  2605.     int length;
  2606. {
  2607.     if (( b1 < b2 ) && (( b1 + length ) > b2 ))
  2608.     {
  2609.     b2 += ( length - 1 );
  2610.     b1 += ( length - 1 );
  2611.     while ( length -- )
  2612.         *b2-- = *b1--;
  2613.     }
  2614.     else
  2615.     {
  2616.     while ( length -- )
  2617.         *b2++ = *b1++;
  2618.     }
  2619.     return 0;
  2620. }
  2621.  
  2622. int
  2623. bcmp ( b1, b2, length )
  2624.     char* b1, * b2;
  2625.     int length;
  2626. {
  2627.     while (( length -- ) && ( *b1++ == *b2++ ));
  2628.  
  2629.     return length + 1;
  2630. }
  2631.  
  2632. int
  2633. bzero ( b, length )
  2634.     char* b;
  2635.     int length;
  2636. {
  2637.     while ( length -- )
  2638.     *b++ = 0;
  2639.  
  2640.     return 0;
  2641. }
  2642. #endif
  2643.  
  2644.